import com.toilet.easyvideofx.util.IPUtil;
import io.helidon.config.Config;
import io.helidon.webserver.WebServer;
import io.helidon.webserver.http.HttpRouting;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.net.*;
import java.util.Enumeration;
import java.util.List;

public class WebSocket {
    public static void main(String[] args) throws UnknownHostException {
        List<String> iPs = IPUtil.getIPs();
        System.out.println(iPs);
    }

    @Test
    public void testGetH5() throws UnknownHostException {
        List<String> iPs = IPUtil.getIPs();
        for (String iP : iPs) {
            URI source = URI.create("http://" + iP + ":9004/static/h5Upload.html");
            try {
                URLConnection connection = source.toURL().openConnection();
                int sourceLength = connection.getContentLength();
                if (sourceLength > 0) {
                    System.out.println(iP);
                }
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        InetAddress localHost = InetAddress.getLocalHost();
        String uploadUrl = "http://" + localHost.getHostAddress();
        System.out.println(uploadUrl);
    }

}
